package Controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPasswordField;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

import Vista.NewJDialogOrden;
import Modelo.*;

import javax.swing.JFrame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Vista.NewJDialogCategoria;
import Vista.NewJDialogDetalleCompra;
import Vista.NewJDialogOrden;
import Vista.NewJDialogPlantilla;
import Vista.NewJDialogProducto;
import Vista.NewJDialogRegistrarCliente;
import Vista.NewJDialogReporteProducto;
import Vista.NewJFramePrincipal;

public class ControladorPrincipal implements ActionListener{
	
   private NewJFramePrincipal principal;
   private ControladorOrden crtOr;
   private ControladorProducto crprod;
   private String password1;
   private ControladorCtegoria categ;
   private ControladorCliente client;
   private ControladorPlantilla plan;
   private ControladorDetalle detalle;
   
   public ControladorPrincipal(JFrame frm) {
	   super ();
	   //this.principal = NewJFramePncipal();
	   //this.principal.addListener(this);
		//this.principal.setVisible(true);
	   principal = new NewJFramePrincipal(this);
		principal.setVisible(true);
		//principal.getjBtoAceptar().setEnabled(false);
		
		password1= "12345";
		principal.getjBtoOrden().addActionListener(new ActionListener() {
			
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//NewJDialogOrden DialogOrden = new NewJDialogOrden(null, crtOr);
				//(ControladorOrden controladorOrden = new ControladorOrden(null);
				//DialogOrden.setVisible(true);
				new ControladorOrden(null);
			
			}
			
			
		});
		
		principal.getjBtoAceptar().addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if(principal.getjPsswPrincipal().getText().equals("12345")){
					
				
				principal.getjBtoReporteProductoCantidad().setEnabled(true);
				principal.getjBtoReporteIngredientes().setEnabled(true);
				principal.getjBtoReporteProductoMonto().setEnabled(true);
				principal.getjBtoIngredientesMasUsados().setEnabled(true);
				}
			}
		});
		
		principal.getjBtoSalir().addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				principal.dispose();
			}
		});
		   
		
		principal.getjPsswPrincipal().addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
			//JPasswordField password = principal.getjPsswPrincipal();
			/*if(principal.getjPsswPrincipal().equals("")){
				principal.mostrarMensaje("Coloque un titulo");
				JButton jBtoAceptar = new JButton();
				jBtoAceptar = principal.getjBtoAceptar();
				jBtoAceptar.setEnabled(false);
			}*/
			//else
			 if(!principal.getjPsswPrincipal().equals("12345")){
				//JButton jBtoAceptar = new JButton();
				//jBtoAceptar = principal.getjBtoAceptar();
				//jBtoAceptar.setEnabled(true);
				principal.getjBtoAceptar().setEnabled(true);
				//principal.setEnabled(jBtoAceptar);				
			}	
			//principal.getjPsswPrincipal().setEnabled(true);
			}			
		});
		
		principal.getjBtoRegistrarProducto().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new ControladorProducto(null);
				//NewJDialogProducto DialogProd = new NewJDialogProducto(null, crprod);
				//DialogProd.setVisible(true);
			}
			
		});
		principal.getjBtoRegistrarCategoria().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new ControladorCtegoria(null);
				//NewJDialogCategoria DialogCat = new NewJDialogCategoria(null, categ);
				//DialogCat.setVisible(true);
			}
			
		});
		
		principal.getjBtoRegistrarCliente().addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				new ControladorCliente(null);
			}
			
		});
		principal.getjBtoRegistrarPlantilla().addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//NewJDialogPlantilla DialogPlan = new NewJDialogPlantilla(null, plan);
				//DialogPlan.setVisible(true);
				new ControladorPlantilla(null);
			}
			
		});
		principal.getjBtoCompra().addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				new ControladorDetalle(null);
			}
			
		});
		principal.getJBtoRegistrarIngre().addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				new ControladorIngrediente(null);
				
			}
		});
		principal.getjBtoReporteProductoMonto().addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//NewJDialogReporteProducto DialogReporte = new NewJDialogReporteProducto(null,   )
			new ControladorReporteProdMonto(null);
			}
			
		});
		principal.getjBtoReporteProductoCantidad().addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				//NewJDialogReporteProducto DialogReporte = new NewJDialogReporteProducto(null,   )
			new ControladorProductoCantidad(null);
			}
			
		});
		
		principal.getjBtoReporteIngredientes().addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				new ControladorReporteIngrediente(null);
			}
		});
   }
private NewJFramePrincipal NewJFramePrincipal() {
	// TODO Auto-generated method stub
	return null;
}
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	
}

}
